import { pgTable, bigserial, varchar, text, bigint, timestamp, integer, vector } from "drizzle-orm/pg-core"
import { sql } from "drizzle-orm"



export const contentDocument = pgTable("content_document", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	title: varchar({ length: 255 }),
	description: text(),
	text: text(),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
	path: varchar({ length: 255 }),
});

export const authRole = pgTable("auth_role", {
	mark: varchar({ length: 255 }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	createTime: timestamp("create_time", { mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const aiSpgSchema = pgTable("ai_spg_schema", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	structure: text(),
	description: text(),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const authMenu = pgTable("auth_menu", {
	name: varchar({ length: 255 }).primaryKey().notNull(),
	supName: varchar("sup_name", { length: 255 }),
	title: varchar({ length: 255 }),
	icon: varchar({ length: 255 }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const authPermission = pgTable("auth_permission", {
	mark: varchar({ length: 255 }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	menuId: bigint("menu_id", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const authRoleMenu = pgTable("auth_role_menu", {
	roleMark: varchar("role_mark", { length: 255 }).notNull(),
	menuName: varchar("menu_name", { length: 255 }).notNull(),
});

export const authRolePermission = pgTable("auth_role_permission", {
	roleMark: varchar("role_mark", { length: 255 }).notNull(),
	permissionMark: varchar("permission_mark", { length: 255 }).notNull(),
});

export const aiKnowledge = pgTable("ai_knowledge", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	type: varchar({ length: 32 }),
	description: text(),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const aiKnowledgeText = pgTable("ai_knowledge_text", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	knowledgeId: bigint("knowledge_id", { mode: "number" }),
	url: varchar({ length: 1024 }),
	format: text(),
	textStatus: integer("text_status"),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const aiKnowledgeTextEmbedding = pgTable("ai_knowledge_text_embedding", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	textId: bigint("text_id", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	knowledgeId: bigint("knowledge_id", { mode: "number" }),
	content: text(),
	embedding: vector({ dimensions: 1536 }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
});

export const aiKnowledgeTu = pgTable("ai_knowledge_tu", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	knowledgeId: bigint("knowledge_id", { mode: "number" }),
});

export const aiSpgEntity = pgTable("ai_spg_entity", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	schemaId: bigint("schema_id", { mode: "number" }),
	primaryKey: varchar("primary_key", { length: 255 }),
	attributes: text(),
	description: text(),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'string' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'string' }),
});

export const aiSpgRelation = pgTable("ai_spg_relation", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	name: varchar({ length: 255 }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	schemaId: bigint("schema_id", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	inEntity: bigint("in_entity", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	outEntity: bigint("out_entity", { mode: "number" }),
	attributes: text(),
	description: text(),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	createBy: bigint("create_by", { mode: "number" }),
	// You can use { mode: "bigint" } if numbers are exceeding js number limitations
	updateBy: bigint("update_by", { mode: "number" }),
	createTime: timestamp("create_time", { precision: 6, mode: 'date' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'date' }),
});

export const authUser = pgTable("auth_user", {
	id: bigserial({ mode: "bigint" }).primaryKey().notNull(),
	avatar: varchar({ length: 255 }),
	nickname: varchar({ length: 255 }),
	username: varchar({ length: 255 }),
	password: varchar({ length: 255 }),
	createTime: timestamp("create_time", { precision: 6, mode: 'date' }),
	updateTime: timestamp("update_time", { precision: 6, mode: 'date' }),
});

export const authUserRole = pgTable("auth_user_role", {
	userId: bigserial("user_id", { mode: "bigint" }).primaryKey().notNull(),
	roleMark: varchar("role_mark", { length: 255 }).notNull(),
});
